﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Lon.Server
{
    public partial class DiagnoForm : Form
    {
        public DiagnoForm()
        {
            InitializeComponent();
        }

        public void Clear()
        {
            this.textBox1.Clear();
        }

        public void WriteLine(string text)
        {
            this.Invoke(new EventHandler(delegate
            {
                this.textBox1.Text = this.textBox1.Text + text + "\r\n\r\n";
            }));

        }

        static List<string> diagnoList = new List<string>();
        public static List<string> DiagnoList
        {
            get { return diagnoList; }
            set { diagnoList = value; }
        }

        protected override void OnLoad(EventArgs e)
        {
            DoAction();
            base.OnLoad(e);
        }

        public void DoAction()
        {
            System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(() =>
            {
                foreach (string lineText in diagnoList)
                {
                    WriteLine(string.Format("{0:G} {1}", DateTime.Now, lineText));
                    System.Threading.Thread.Sleep(250);
                }

                WriteLine(string.Format("{0:G} 自检完毕!", DateTime.Now));

            }));

            thread.IsBackground = true;
            thread.Start();
        }


    }

}
